package com.song.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.song.dao.RoomDao;

import com.song.po.Room;
import com.song.service.RoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RoomServiceImpl implements RoomService {
   @Autowired
   private RoomDao roomDao;

   @Override
   public List<Room> getAllRoomList() {
      List<Room> list = roomDao.selectList(null);
      return list;
   }

   @Override
   public List<Room> getRoomByWrapper(Room room) {
      QueryWrapper<Room> queryWrapper = new QueryWrapper<>();
      if(room.getRoomAddress() != null && !(room.getRoomAddress() .equals(""))){
         queryWrapper.like("room_address",room.getRoomAddress());
      }
      if(room.getRend() != null && !(room.getRend() .equals(""))){
         queryWrapper.like("rend",room.getRend());
      }
      if(room.getRoomStatus() != null && !(room.getRoomStatus() .equals(""))){
         queryWrapper.like("room_status",room.getRoomStatus());
      }
      if(room.getRoomType() != null && !(room.getRoomType() .equals(""))){
         queryWrapper.like("room_type",room.getRoomType());
      }
      List<Room> list = roomDao.selectList(queryWrapper);
      return list;
   }
}
